package xyz.haijin.zt.core.exception;

import xyz.haijin.zt.core.constant.ErrorCodes;

/**
 * @author liuhaijin
 * @date 2022/4/18
 */
public class BusinessException extends BaseException {

    private int code;
    private String message;

    public BusinessException(int code, String message, Throwable cause) {
        super(message, cause);
        this.code = code;
        this.message = message;
    }

    public BusinessException(int code, String message) {
        super(message, null);
        this.code = code;
        this.message = message;
    }

    public BusinessException(String message) {
        super(message, null);
        this.code = ErrorCodes.ERROR_OTHER;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    @Override
    public int errorCode() {
        return this.code;
    }
}
